home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / c3 / pro15 / dazzle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-02-24  |  16.1 KB  |  770 lines

  1. /***************************************************************************
  2.  * dazzle.c
  3.  *
  4.  *            A simple graphics program demo for the Amiga by
  5.  *            M. Peter Engelbrite
  6.  *
  7.  *          A note about the name "dazzle"- back in the days of
  8.  *          MITS(Altair), SWTP and Processor Technology, there was
  9.  *          a color graphics board for the S-100 named the "Dazzler".
  10.  *          A computer program came with this board named "Dazzle".
  11.  *          That program had the same type of eight-fold symmetry that
  12.  *          my program does (although it was much simpler in the
  13.  *          generation of the patterns).  Legend has it that a 'mystery'
  14.  *          programmer wrote that program in a few hours, and sold it
  15.  *          to Chromemco (the manufacturer) for a song.  Whenever I
  16.  *          experiment with a graphics system,  I test it with some
  17.  *          version of this program and name it Dazzle in honor of that
  18.  *          mystery programmer.
  19.  *
  20.  *            Many thanks to Scott Ballantyne for "sparks", portions of
  21.  *          which were used in this program.
  22.  *
  23.  ************************************************************************/
  24.  
  25. /* Because of a wierd bug in the current Manx C compiler I am using */
  26. /* (versions 1.99G), the comments below have been moved to their current */
  27. /* location, from the end of the include file lines.  Fred Fish, 3/8/86 *
  28.  
  29. /* Not all of these are used -- I include them */
  30. /* 'cause I'm sick of compiler warnings.       */
  31. #pragma inline
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <time.h>
  35.  
  36. #define MAXX   320
  37. #define MAXY   200
  38. #define row 100
  39. #define col 150
  40. #define INIT 1
  41. #define EXEC 0
  42.  
  43. /* if you make any changes, please update the version number 
  44.    following the decimal */
  45.  
  46. int PauseMode, TitleOn;
  47. int offsa, offsb;
  48. int color, cyclecnt;
  49. unsigned char *Epal;
  50.  
  51. /* these are utility functions for use in changing colors */
  52. /* randomly select a new color, also randomizes the hue for that color */
  53. newcolor()
  54. {
  55.     color = RangeRand(255) + 1; /* leave lower colors alone */
  56.   /* give it a new look, also */
  57.     Epal[color*3] = (Epal[(color-1)*3] + RangeRand(6))%32;
  58.     Epal[color*3+1] = (Epal[(color-1)*3+1] + RangeRand(6))%32;
  59.     Epal[color*3+2] = (Epal[(color-1)*3+2] + RangeRand(6))%32;
  60.     SetPal( Epal );
  61. }
  62.  
  63. /* selects the next in sequence of available colors */
  64. nextcolor()
  65. {
  66.   if(++color > 255) color = 1;
  67. }
  68.  
  69. /* sets a specific color */
  70. setcolor(coler)
  71. int coler;
  72. {
  73.   color = coler;
  74.   if(color == 0) color = 1;
  75. }
  76.  
  77. /* user definable graphics functions */
  78. /* each function should set offsa and offsb and optionally chage the color
  79.    it may maintain local variables, it should accept a value init which
  80.    is set to TRUE to indicate that initialization is to occur.  offsa and
  81.    offsb should range between 0 and 99 (overflow is not fatal, though).
  82.    The function may call setcolor(n), newcolor(), or nextcolor() to change
  83.    the color.  The name of your function must be added to the structure
  84.    dotfunc in do_dazzle() at the end of this module.  You will find that
  85.    it is very easy to experiment and obtain interesting effects.
  86. */
  87.  
  88. streamer(init)
  89. int init;
  90. {
  91.   static int cnt1, cnt2, cnt3;
  92.  
  93.   if(init)
  94.     {
  95.       cnt1 = cnt2 = 0;
  96.       cnt3 = 24;
  97.     }
  98.   if(cnt1++ > cnt2)
  99.     {
  100.       offsa -= cnt2;
  101.       cnt1 = 0;
  102.       cnt2 = cnt2 + 1;
  103.       if (cnt2 > cnt3)
  104.         {
  105.           cnt2 = 0;
  106.           if((cnt3 = cnt3 + RangeRand(4)) > 44) cnt3 = 0; 
  107.         }
  108.       if(offsb++ >= 99) offsb = 0;
  109.     }
  110.   if(offsa++ >= 99) offsa = 0;
  111.   if(RangeRand(1000) == 0) newcolor();
  112. }
  113.  
  114. lotsadots(init)
  115. int init;
  116. {
  117.         offsa = RangeRand(100);
  118.         offsb = RangeRand(100);
  119.         newcolor();
  120. }
  121.  
  122. ribbons(init)
  123. int init;
  124. {
  125.   static int cnt1, cnt2, cnt3;
  126.  
  127.   if(init)
  128.     {
  129.       cnt1 = cnt2 = 0;
  130.       cnt3 = 24;
  131.     }
  132.   if(cnt1++ > cnt2)
  133.     {
  134.       offsa -= cnt2;
  135.       cnt1 = 0;
  136.       cnt2 = cnt2 + 1;
  137.       if (cnt2 > cnt3)
  138.         {
  139.           cnt2 = 0;
  140.           if((cnt3 = cnt3 + RangeRand(4)) > 44) cnt3 = 0; 
  141.         }
  142.       nextcolor();
  143.       if(offsb++ >= 99) offsb = 0;
  144.     }
  145.   if(offsa++ >= 99) offsa = 0;
  146.   if(RangeRand(1000) == 0) newcolor();
  147. }
  148.  
  149.  
  150. scribble(init)
  151. int init;
  152. {
  153.  
  154.   if((offsa = offsa + RangeRand(3) - 1) > 99) offsa = 0;
  155.   if((offsb = offsb + RangeRand(3) - 1) > 99) offsb = 0;
  156.   if(RangeRand(500) == 0) newcolor();
  157. }
  158.  
  159. curves(init)
  160. int init;
  161. {
  162.   static int wid, andx, bndx, aspeed, bspeed;
  163.  
  164.   if(init)
  165.     {
  166.       andx = bndx = wid = 0;
  167.       aspeed = RangeRand(64) + 20;
  168.       bspeed = RangeRand(64) + 20;
  169.       newcolor();
  170.     }
  171.  
  172.   if((wid = (wid + 1) & 15) == 0)
  173.     {
  174.       offsa = (int)(sin((double)andx * .0005) * 42.0) + 42;
  175.       offsb = (int)(sin((double)bndx * .0005) * 42.0) + 42;
  176.       andx += aspeed;
  177.       bndx += bspeed;
  178.       if(andx > 32000) andx = 0;
  179.       if(bndx > 32000) bndx = 0;
  180.       nextcolor();
  181.     }
  182.   else
  183.     offsa++;
  184. }
  185.  
  186. lines(init)
  187. int init;
  188. {
  189.   static int wid, aspeed, bspeed, ndx;
  190.  
  191.   if(init)
  192.     {
  193.       wid = ndx = 0;
  194.       aspeed = bspeed = 1;
  195.     }
  196.   if((wid = (wid + 1) & 3) == 0)
  197.     {
  198.       offsa += aspeed;
  199.       ndx += bspeed;
  200.       if(offsa < 0)
  201.         {
  202.           aspeed = 1;
  203.           offsa = 0;
  204.           if(RangeRand(3) == 0) newcolor();
  205.         }
  206.       if(ndx < 0)
  207.         {
  208.           bspeed = RangeRand(4) + 1;
  209.           ndx = 0;
  210.         }
  211.       if(offsa >= 100)
  212.         {
  213.           aspeed = - 1;
  214.           offsa = 99;
  215.         }
  216.       if(ndx >= 97)
  217.         {
  218.           bspeed = 0 - (RangeRand(4) + 1);
  219.           ndx = 96;
  220.          }
  221.       offsb = ndx;
  222.     }
  223.   else
  224.     offsb++;
  225. }
  226.  
  227. squares(init)
  228. int init;
  229. {
  230.         static int aend, astrt, sqcnt;
  231.  
  232.         if(init) sqcnt = 0;
  233.         if(sqcnt != 0) {
  234.                 if(++offsa > aend) {
  235.                         offsa = astrt;
  236.                         offsb++;
  237.                         sqcnt--;
  238.                         if(offsb > 99) {
  239.                                 sqcnt = 0;
  240.                                 offsb = 99;
  241.                         }
  242.                    nextcolor();
  243.                 }
  244.         }
  245.         if(sqcnt == 0) {
  246.                 sqcnt = (RangeRand(10)) + 8;
  247.                 offsa = (astrt = RangeRand(64));
  248.                 aend = (RangeRand(64)) + astrt + 8;
  249.                 if(aend > 99) aend = 99;
  250.                 while((offsb = RangeRand(128)) > 99);
  251.                 newcolor();
  252.         }
  253. }
  254.  
  255. triangles(init)
  256. int init;
  257. {
  258.         static int aend, astrt, sqcnt;
  259.  
  260.         if(init) sqcnt = 0;
  261.         if(sqcnt != 0) {
  262.                 if(++offsa > aend) {
  263.                         nextcolor();
  264.                         astrt++;
  265.                         aend--;
  266.                         if(astrt >= aend) {
  267.                                 sqcnt = 0;
  268.                         } else {
  269.                                 offsa = astrt;
  270.                                 offsb++;
  271.                                 if(offsb > 99) {
  272.                                         sqcnt = 0;
  273.                                         offsb = 99;
  274.                                 }
  275.                         }
  276.                 }
  277.         }
  278.         if(sqcnt == 0) {
  279.                 sqcnt = 1;
  280.                 offsa = (astrt = RangeRand(64));
  281.                 aend = RangeRand(64) + astrt + 8;
  282.                 if(aend > 99) aend = 99;
  283.                 offsb = RangeRand(100);
  284.                 newcolor();
  285.         }
  286. }
  287.  
  288. zigzags(init)
  289. int init;
  290. {
  291.   static int cnt, andx, bndx;
  292.  
  293.   if(init) cnt = -1;
  294.   if(cnt-- <= 0)
  295.     {
  296.       andx = RangeRand(3) - 1;
  297.       bndx = RangeRand(3) - 1;
  298.       cnt = RangeRand(15);
  299.       newcolor();
  300.     }
  301.   offsa += andx;
  302.   offsb += bndx;
  303.   if(offsa <= 0 || offsa >= 99) andx = -andx;
  304.   if(offsb <= 0 || offsb >= 99) bndx = -bndx;
  305.  
  306. }
  307.  
  308. grid(init)
  309. int init;
  310. {
  311.   static int aend, astrt, xcol, imagepnt, imagestrt;
  312.   static char image[] =
  313.     {
  314.  
  315.       0,0,0,1,1,0,0,0,
  316.       0,0,0,1,1,0,0,0,
  317.       0,0,0,0,1,1,0,0,
  318.       1,1,0,0,0,1,1,1,
  319.       1,1,1,0,0,0,1,1,
  320.       0,0,1,1,0,0,0,0,
  321.       0,0,0,1,1,0,0,0,
  322.       0,0,0,1,1,0,0,0,
  323.  
  324.       0,0,0,1,1,0,0,0,
  325.       0,0,0,1,1,0,0,0,
  326.       0,0,1,1,0,0,0,0,
  327.       1,1,1,0,0,0,1,1,
  328.       1,1,0,0,0,1,1,1,
  329.       0,0,0,0,1,1,0,0,
  330.       0,0,0,1,1,0,0,0,
  331.       0,0,0,1,1,0,0,0,
  332.  
  333.       0,0,0,1,1,0,0,0,
  334.       0,0,0,1,1,0,0,0,
  335.       0,0,0,1,1,0,0,0,
  336.       1,1,0,1,1,0,1,1,
  337.       1,1,0,1,1,0,1,1,
  338.       0,0,0,1,1,0,0,0,
  339.       0,0,0,1,1,0,0,0,
  340.       0,0,0,1,1,0,0,0,
  341.  
  342.       0,0,0,1,1,0,0,0,
  343.       0,0,0,1,1,0,0,0,
  344.       0,0,0,0,0,0,0,0,
  345.       1,1,1,1,1,1,1,1,
  346.       1,1,1,1,1,1,1,1,
  347.       0,0,0,0,0,0,0,0,
  348.       0,0,0,1,1,0,0,0,
  349.       0,0,0,1,1,0,0,0,
  350.  
  351.     };
  352.  
  353.   if((imagepnt & 63) == 0 || init)
  354.     {
  355.       imagestrt = RangeRand(4) * 64;
  356.       offsa = RangeRand(12) * 8;
  357.       astrt = offsa;
  358.       aend = offsa + 7;
  359.       offsb = RangeRand(12) * 8;
  360.       imagepnt = imagestrt;
  361.       if(RangeRand(25) == 0)
  362.         {
  363.           newcolor();
  364.           xcol = RangeRand(24) + 5;
  365.         }
  366.       offsa--;
  367.     }
  368.   if(++offsa > aend)
  369.     {
  370.       offsa = astrt;
  371.       offsb++;
  372.     }
  373.   color = (image[imagepnt++]) ? xcol : 0;
  374. }
  375.  
  376. diag1(init)
  377. int init;
  378. {
  379.         offsb--;
  380.         if(offsa++ > 98) {
  381.                 offsa = 0;
  382.                 offsb++;
  383.                 nextcolor();
  384.         }
  385.         if(offsb < 0) {
  386.                 offsb = 99;
  387.         }
  388. }
  389.  
  390. diag2(init)
  391. int init;
  392. {
  393.         offsb++;
  394.         if(offsa++ > 98) {
  395.                 offsa = 0;
  396.                 offsb--;
  397.                 nextcolor();
  398.         }
  399.         if(offsb > 99) {
  400.                 offsb = 0;
  401.         }
  402. }
  403.  
  404. diag3(init)
  405. int init;
  406. {
  407.   static int cnt, cnt2;
  408.  
  409.   if(init) cnt = cnt2 = 0;
  410.  
  411.   offsb++;
  412.   if(offsa++ > 98)
  413.     {
  414.       offsa = 0;
  415.       offsb--;
  416.       color = 4;
  417.       if(++cnt2 > 20) cnt2 = 0;
  418.     }
  419.   if(cnt++ > cnt2)
  420.     {
  421.       cnt = 0;
  422.       if(color++ > 255) color = 4;
  423.     }
  424.   if(offsb > 99) offsb = 0;
  425. }
  426.  
  427. diag4(init)
  428. int init;
  429. {
  430.         offsb--;
  431.         if(offsa++ > 98) {
  432.                 offsa = 0;
  433.                 offsb++;
  434.         }
  435.         if(offsb < 0) {
  436.                 offsb = 99;
  437.         }
  438.   setcolor(((offsa * offsb) >> 4) & 31);
  439. }
  440.  
  441. sweep(init)
  442. int init;
  443. {
  444.   static int ainc, alen;
  445.  
  446.   if(init || alen > 51)
  447.     {
  448.       alen = ainc = offsa = offsb = 0;
  449.     }
  450.   if(ainc++ > alen)
  451.     {
  452.       offsb++;
  453.       ainc = 0;
  454.     }
  455.   if(offsa++ >= 99)
  456.     {
  457.       nextcolor();
  458.       alen++;
  459.       offsa = offsb = 0;
  460.     }  
  461. }
  462.  
  463. fadein(init)
  464. int init;
  465. {
  466.         offsa = RangeRand(99) + 1;
  467.         offsb = RangeRand(99) + 1;
  468.         setcolor(offsa / offsb);
  469. }
  470.  
  471. spiral(init)
  472. int init;
  473. {
  474.   static int sidecnt, sidelen, colorcnt, dirndx, adir, bdir;
  475.   static int newadir[] = {0,1,0,-1};
  476.   static int newbdir[] = {1,0,-1,0};
  477.  
  478.   if(init || offsa >= 99 || offsb >= 99)
  479.     {
  480.       sidecnt = 100;
  481.       sidelen = 0;
  482.       dirndx = 0;
  483.       offsa = RangeRand(99);
  484.       offsb = RangeRand(99);
  485.       colorcnt = 0;
  486.     }
  487.   if(sidecnt++ >= sidelen)
  488.     {
  489.       sidecnt = 0;
  490.       dirndx = (dirndx + 1) & 3;
  491.       if((dirndx & 1) == 0) sidelen++;
  492.       adir = newadir[dirndx];
  493.       bdir = newbdir[dirndx];
  494.     }
  495.   offsa += adir;
  496.   offsb += bdir;
  497.   if((colorcnt++ & 3) == 0) nextcolor();
  498.  
  499. }
  500.  
  501. spiral1(init)
  502. int init;
  503. {
  504.   static int sidecnt, sidelen, dirndx, adir, bdir, size;
  505.   static int newadir[] = {1,1,-1,-1};
  506.   static int newbdir[] = {1,-1,-1,1};
  507.  
  508.   if(init || offsa >= 99 || offsb >= 99 || sidelen >= size)
  509.     {
  510.       sidecnt = 100;
  511.       sidelen = 0;
  512.       dirndx = 0;
  513.       offsa = RangeRand(99);
  514.       offsb = RangeRand(99);
  515.       size = RangeRand(70);
  516.     }
  517.   if(sidecnt++ >= sidelen)
  518.     {
  519.       sidecnt = 0;
  520.       if(++dirndx > 3)
  521.         {
  522.           sidelen++;
  523.           offsa--;
  524.           dirndx = 0;
  525.           nextcolor();
  526.         }
  527.       adir = newadir[dirndx];
  528.       bdir = newbdir[dirndx];
  529.     }
  530.   offsa += adir;
  531.   offsb += bdir;
  532. }
  533.  
  534. zigstream(init)
  535. int init;
  536. {
  537.   static int sidecnt, sidelen, colorcnt, dirndx, adir, bdir;
  538.   static int newadir[] = {0,1};
  539.   static int newbdir[] = {1,0};
  540.  
  541.   if(init || offsa >= 99 || offsb >= 99)
  542.     {
  543.       sidecnt = 100;
  544.       sidelen = 0;
  545.       dirndx = 0;
  546.       offsa = RangeRand(99);
  547.       offsb = RangeRand(99);
  548.       colorcnt = 0;
  549.       setcolor(4);
  550.     }
  551.   if(sidecnt++ >= sidelen)
  552.     {
  553.       sidecnt = 0;
  554.       if((++dirndx & 1) == 0)
  555.         {
  556.           sidelen++;
  557.           dirndx = 0;
  558.         }
  559.       adir = newadir[dirndx];
  560.       bdir = newbdir[dirndx];
  561.     }
  562.   offsa += adir;
  563.   offsb += bdir;
  564.   if((colorcnt++ & 3) == 0) nextcolor();
  565.  
  566. }
  567.  
  568. formula1(init)
  569. int init;
  570. {
  571.   static int cona, conb, conx;
  572.  
  573.   if(init || offsa > 99)
  574.     {
  575.       offsa = 0;
  576.       offsb = -1;
  577.       cona = RangeRand(2) + 1;
  578.       conb = RangeRand(3) + 1;
  579.       conx = RangeRand(4) + 2;
  580.     }
  581.   if(offsb++ > offsa)
  582.     {
  583.       offsa++;
  584.       offsb = 0;
  585.     }
  586.   setcolor(((offsb * offsb * conb) - (offsa << cona)) >> conx);
  587. }
  588.  
  589. cycolor()
  590. {
  591.     int i, j;
  592.     char red, green, blue;
  593.  
  594.     red = Epal[3];
  595.     green = Epal[4];
  596.     blue = Epal[5];
  597.     for( i=1; i<255; i++ )
  598.     {
  599.         for( j=0; j<3; j++ )
  600.             Epal[i*3+j] = Epal[(i+1)*3+j];
  601.     }
  602.     Epal[255*3] = red;
  603.     Epal[255*3+1] = green;
  604.     Epal[255*3+2] = blue;
  605.     SetPal( Epal );
  606.     cyclecnt = 50;
  607. }
  608.  
  609. do_dazzle()
  610. {
  611.     int (*currentfunc)();
  612.     int type, typecnt, typetime;
  613.  
  614.     struct dotfuncs
  615.     {
  616.         int (*func)();
  617.         int maxtime;
  618.     };
  619.  
  620. /* add the names of the custom graphics functions here */
  621.     static struct dotfuncs dotfunc[] =
  622.     {
  623. /*    function name,    number of cycles to run (randomized) */
  624.         formula1,        15000,
  625.         lotsadots,    6000,
  626.         streamer,        2000,
  627.         ribbons,        6000,
  628.         curves,        6000,
  629.         lines,        4000,
  630.         squares,        6000,
  631.         triangles,    8000,
  632.         zigzags,        6000,
  633.         grid,            6000,
  634.         diag1,        8000,
  635.         diag2,        8000,
  636.         diag3,        12000,
  637.         diag4,        12000,
  638.         sweep,        3000,
  639.         fadein,        15000,
  640.         spiral,        15000,
  641.         spiral1,        15000,
  642.         zigstream,    10000
  643.     };
  644.  
  645.     newcolor();
  646.     cyclecnt = offsa = offsb = 0;
  647.     typecnt = 100;
  648.     typetime = 10;
  649.  
  650.     while( 1 )
  651.    {
  652.         if( bioskey(1) )
  653.             return;
  654.         if(typecnt++ > typetime)
  655.       {
  656.           type = RangeRand((sizeof(dotfunc) / sizeof(struct dotfuncs)));
  657.           typecnt = 0;
  658.           typetime = RangeRand(dotfunc[type].maxtime);
  659.           if(RangeRand(5) == 0)
  660.           {
  661.               /* clear screen here */
  662.               clr_screen();
  663.               newcolor();
  664.             }
  665.             currentfunc = dotfunc[type].func;
  666.             (*currentfunc)(INIT); /* initialize */
  667.         }
  668.         (*currentfunc)(EXEC);                
  669.         if(offsa > 99)
  670.             offsa = 99;
  671.         if(offsb > 99)
  672.             offsb = 99;
  673.         if(cyclecnt-- <= 0)
  674.             cycolor();
  675.         WritePixel( col + offsb, row + offsa);
  676.         WritePixel( col + offsb, row - offsa);
  677.         WritePixel( col - offsb, row + offsa);
  678.         WritePixel( col - offsb, row - offsa);
  679.         WritePixel( col + offsa, row + offsb);
  680.         WritePixel( col + offsa, row - offsb);
  681.         WritePixel( col - offsa, row + offsb);
  682.         WritePixel( col - offsa, row - offsb);
  683.     }
  684. }
  685.  
  686. setcolors()
  687. {
  688.     printf( "Dazzle 1.1 by M. Peter Engelbrite\n" );
  689.     printf( "Turbo C version by Gary F. Syck\n" );
  690.     printf( "\n\n\n\nPress Any Key" );
  691.     bioskey( 0 );
  692.     Epal[0] = 0;
  693.     Epal[1] = 0;
  694.     Epal[2] = 0;
  695.     Epal[3] = RangeRand(32);
  696.     Epal[4] = RangeRand(32);
  697.     Epal[5] = RangeRand(32);
  698.     for( color=2; color<256; color++ )
  699.     {
  700.         Epal[color*3] = (Epal[(color-1)*3] + RangeRand(6))%32;
  701.         Epal[color*3+1] = (Epal[(color-1)*3+1] + RangeRand(6))%32;
  702.         Epal[color*3+2] = (Epal[(color-1)*3+2] + RangeRand(6))%32;
  703.     }
  704.     SetPal( Epal );
  705.     clr_screen();
  706. }
  707.  
  708. main()
  709. {
  710.     long t;
  711.  
  712.     Epal = malloc( 3*256 );
  713.     clr_screen();
  714.     setcolors();
  715.  
  716.     time( &t );
  717.     srand((int) t );
  718.    do_dazzle();
  719.     bioskey( 0 );
  720.     _AX = 0x3;
  721.     asm    int    10h;
  722. }
  723.  
  724. int RangeRand( rng )
  725. int rng;
  726. {
  727.     return rand()%rng;
  728. }
  729.  
  730. WritePixel( x, y )
  731. int x, y;
  732. {
  733.     _DX = y;
  734.     _CX = x;
  735.     _AL = color;
  736.     _AH = 0xc;
  737.     asm    int    10h;
  738. }
  739.  
  740. clr_screen()
  741. {
  742.     _AX = 0x13;        /* set mode 13 */
  743.     asm    int    10h;
  744. }
  745.  
  746. GetPal( Buf )
  747. char *Buf;
  748. {
  749.     asm    push    ds;
  750.     asm    pop    es;
  751.     _DX = Buf;
  752.     _BX = 0;
  753.     _CX = 256;
  754.     _AX = 0x1017;
  755.     asm    int    10h;
  756. }
  757.  
  758. SetPal( Buf )
  759. char *Buf;
  760. {
  761.     asm    push    ds;
  762.     asm    pop    es;
  763.     _DX = Buf;
  764.     _BX = 0;
  765.     _CX = 256;
  766.     _AX = 0x1012;
  767.     asm    int    10h;
  768. }
  769.  
  770.